package com.android.boncen.commonFrame;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentActivity;

import com.android.boncen.commonFrame.bean.UserBean;

import cn.bmob.v3.BmobUser;

/***
 * 欢迎
 */
public class LaunchActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launch);


        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {

                UserBean bmobUser = BmobUser.getCurrentUser(UserBean.class);
                if (bmobUser != null) {
                    // 允许用户使用应用
                    Intent intent = new Intent(LaunchActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    //缓存用户对象为空时， 可打开用户注册登录界面…
                    Intent intent = new Intent(LaunchActivity.this, LoginActivity.class);
                    startActivity(intent);
                    finish();
                }

            }
        }, 2000);
    }
}
